export const formatPutoutData = (createdAt) => {
    const currentDate = new Date()
    const createdAtDate = new Date(createdAt)

    const timeDifferenceInSeconds = Math.floor((currentDate - createdAtDate) / 1000)
    const timeDifferenceInMinutes = Math.floor(timeDifferenceInSeconds / 60)
    const timeDifferenceInHours = Math.floor(timeDifferenceInMinutes / 60)
    const timeDifferenceInDays = Math.floor(timeDifferenceInHours / 24)


    if (timeDifferenceInDays > 1) {
        // more than 1 day
        return createdAtDate.toLocaleDateString("en-US", {
            month: "short",
            day: "numeric",
        })
    } else if (timeDifferenceInDays === 1) {
        // equal to 1 day
        return "1d"
    } else if (timeDifferenceInHours >= 1) {
        // >= 1 hour
        return `${timeDifferenceInHours}h`
    } else if (timeDifferenceInMinutes >= 1) {
        return `${timeDifferenceInMinutes}m`
    } else {
        return "Just now"
    }
}


export const formatMemberSinceData = (createdAt) => {
    const date = new Date(createdAt)
    const months = [
        "January",// 1
        "February",// 2
        "March",// 3
        "April",// 4
        "May",// 5
        "June",// 6
        "July",// 7
        "August",// 8
        "September",// 9
        "October",// 10
        "November",// 11
        "December",// 12
    ]

    const month = months[date.getMonth()]
    const year = date.getFullYear()

    return `Joined ${year} ${month}`
}